package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;

import java.time.Year;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
@ToString
public class TravelCommend extends BaseDomain {
    public static final Integer TYPE_WEEK = 1; //每周
    public static final Integer TYPE_MONTH = 2; //每月
    public static final Integer TYPE_STRATEGY = 3; //攻略

    private Long travelId;

    private String title;

    private String subTitle;

    private String coverUrl;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date schedule;

    private Integer type;

    public Object getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("travelId", travelId);
        map.put("title", title);
        map.put("subTitle", subTitle);
        map.put("coverUrl", coverUrl);
        map.put("type", type);
        map.put("schedule", DateUtil.formatDate(schedule));
        return JSON.toJSONString(map);
    }

    public String getTypeName() {
        String str = "";
        if (type == TYPE_WEEK) {
            str = "每周推荐";
        } else if (type == TYPE_MONTH) {
            str = "每月推荐";
        } else {
            str = "攻略";
        }
        return str;
    }


}